Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Pushhandler #23

Closed
wants to merge 2 commits into from
Closed

Conversation

DanielMorsing
Copy link
Contributor

This is the initial implementation of server push. There's still a lot to do. Consider this pull request more of a request for comments on the design rather than final code push.

@@ -764,7 +767,7 @@ type HeadersFrameParam struct {
// EndStream indicates that the header block is the last that
// the endpoint will send for the identified stream. Setting
// this flag causes the stream to enter one of "half closed"
// states.
// states. It is not sent if this write is a push promise
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but there's no period at the end of this (and many of your other) comment sentence, which isn't consistent.

@bradfitz
Copy link
Owner

bradfitz commented Dec 8, 2014

There was a thread on [email protected] with title "Pushing 304's" about pushing HEAD requests. So we should probably make that possible.

I can't review this for a couple days, but thanks for starting to tackle it.

As predicted, I ended up unifying the Headers and Push Promise packing.

This is in preparation for reusing the writeResHeaders functionality
of sending continuation frames if the headers are too big.
The API uses loopback to the top handler in order to make sure that
the resources being pushed are related to the resource being fetched.

If the header parameter is nil, we copy the headers from the initiating
request. This is mostly a shortcut for the common case where we don't
want to specify any new request headers.
@brk0v
Copy link

brk0v commented Mar 15, 2015

You've missed to implement push counter for streams in the startPushPromise function. And we can get RST_STREAM from server with PROTOCOL_ERROR. It tries to decrement counter curOpenStreams here:

func (sc *serverConn) closeStream(st *stream, err error) {
    sc.serveG.check()
    if st.state == stateIdle || st.state == stateClosed {
        panic(fmt.Sprintf("invariant; can't close stream in state %v", st.state))
    }
    st.state = stateClosed
    sc.curOpenStreams--

And in case of 0 we get: 4294967295. And then we try to check it here:

func (sc *serverConn) processHeaderBlockFragment(st *stream, frag []byte, end bool) error {   

        ...

    if sc.curOpenStreams > sc.advMaxStreams {
        // "Endpoints MUST NOT exceed the limit set by their
        // peer. An endpoint that receives a HEADERS frame
        // that causes their advertised concurrent stream
        // limit to be exceeded MUST treat this as a stream
        // error (Section 5.4.2) of type PROTOCOL_ERROR or
        // REFUSED_STREAM."
        if sc.unackedSettings == 0 {
            // They should know better.
            return StreamError{st.id, ErrCodeProtocol}
        }

I could not find how to add patch here so I sent new pull request: #34

Thank you.

@DanielMorsing
Copy link
Contributor Author

Sorry about leaving this for so long.

Right now there are multiple issues with the code. Along with the curopenstreams issue that you discovered, we also need to take into account the clientMaxStreams variable that limits the amount of push promises that a server can initiate with a client concurrently.

I have some free time today, so I'll probably push some new code soon.

@DanielMorsing
Copy link
Contributor Author

Nevermind, I looks like you fixed this independently. I'll wait for Brad to have a look. He's on vacation though, so it might be a while.

@bradfitz
Copy link
Owner

This repo just moved into the official Go repo.

See https://github.com/bradfitz/http2/blob/master/README for the move details.

File new bugs at: https://github.com/golang/go/issues/new?title=x/net/http2:+

Closing this PR as we're now using Gerrit for code review. Please file a bug or send the review to Gerrit if this is still relevant. Sorry for how long this languished here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants